Rasterex Database server back-end
You can get our db back-end from our github here.
DB back-end
https://github.com/Rasterex-Software/dbbackend
rx-back-end
Backend service for authentication, web socket, user management, projects, and annotations.
Set up viewer to use db
In order for the Rasterex Web Viewer to get access to your db back end you will need to provide a valid URL to the db back-end server in the assets/scripts/rxconfig.js file
The line to change in rxconfig.js is this line. This will default point to the official Rasterex db back-end server.
var apiBaseURL = "https://rxserver.rasterex.com/";
//change to your own server location
var apiBaseURL = "https://myserver.mydomain.com/";
Quick Start Checklist
Follow these steps to set up the rx-back-end for the first time:
This db-backend requires Node.js and PostgreSQL to be installed on the server.
-
Install prerequisites
- Install Node.js v18+ (includes npm)
- Install PostgreSQL v17+
-
Acquire and prepare project files
- Option A: Clone the repository (developer setup)
git clone <repo-url>
cd rx-back-end - Option B: Copy files to the server (deployment setup)
- Create a folder on the server, e.g.
C:\rx-back-end(Windows) or/opt/rx-back-end(Linux). - Copy the following into that folder:
app/(source files:controllers/,models/,routes/, etc.)server.jsseed.jsswagger.jspackage.jsonpackage-lock.jsonScripts/(SQL setup scripts).env.exampledocs/(documentation)
- Create a folder on the server, e.g.
- Option A: Clone the repository (developer setup)
-
Install dependencies
Open a terminal/command prompt, navigate to the folder where the files are located, and run:npm install -
Configure environment variables
-
Copy
.env.exampleto.env -
Update database credentials, server port, and CORS origin
-
On Linux/Mac:
cp .env.example .env -
On Windows (PowerShell/Command Prompt):
copy .env.example .env
Example
.envvalues:# Database configuration
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=rxdb
# Server port
PORT=8080
# Allowed origin (CORS)
# Set this to the frontend domain that will connect to the API.
# For development, use http://localhost:4200
ALLOWED_ORIGIN=https://myserver.mydomain.com -
-
Set up the database
-
Run provided scripts from the
Scripts/folder:- Windows:
./Scripts/setup_db.bat - Linux/Mac:
./Scripts/setup_db.sh
- Windows:
-
Or run SQL manually with
psql:psql -U <username> -d rxdb -f Scripts/create_tables.sql
psql -U <username> -d rxdb -f Scripts/schema.sql
psql -U <username> -d rxdb -f Scripts/insert_data.sql -
To reset the database:
- Windows:
./Scripts/drop_tables.bat - Manual:
psql -U <username> -d rxdb -f Scripts/drop_tables.sql
- Windows:
-
-
Start the backend server
npm start- Server runs at http://localhost:8080
- Swagger docs available at http://localhost:8080/api-docs
-
(Optional) Run as a service with PM2
PM2 is a process manager for Node.js. It keeps the backend running in the background, restarts it if it crashes, and can auto-start on boot.
- Install PM2 globally:
npm install -g pm2
pm2 -v - Start the service:
pm2 start server.js --name "rx-backend" - Monitor logs and processes:
pm2 ps
pm2 logs rx-backend - Stop or restart:
pm2 stop rx-backend
pm2 restart rx-backend - Enable auto-start on reboot:
pm2 startup
pm2 save
- Install PM2 globally:
Troubleshooting
- Port already in use → Change
PORTin.env. - DB connection errors → Verify PostgreSQL is running,
.envvalues are correct. - Swagger not loading → Ensure the server runs without errors (
npm start). - CORS issues → Update
ALLOWED_ORIGINin.envto match your frontend domain.